Skilled in SEO, content writing, and digital marketing. Completed several years of working in many organizations including multinational companies. I love to learn new things in life that keep me motivated.
Sure, here is how you can get a list of installed Windows fonts using Python:
Python
import winreg
def get_installed_fonts():
"""Gets a list of installed Windows fonts."""
fonts = []
# Get the registry key for the installed fonts.
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts")
# Enumerate the values in the registry key.
for value in winreg.EnumKey(key, 0):
font_path = winreg.QueryValueEx(key, value)[0]
# Add the font to the list.
fonts.append(font_path)
return fonts
if __name__ == "__main__":
fonts = get_installed_fonts()
for font in fonts:
print(font)
This code will first import the winreg module, which is used to access the Windows registry. Then, it will define a function called
get_installed_fonts(). This function will get the registry key for the installed fonts and enumerate the values in the key. For each value, it will get the font path and add it to a list. Finally, the function will return the list of fonts.
The get_installed_fonts() function can be called from the main body of the program. This will print a list of all the installed Windows fonts to the console.
Liked By
Write Answer
How to get a list of installed windows fonts using python?
Join MindStick Community
You have need login or register for voting of answers or question.
Aryan Kumar
25-Jul-2023Sure, here is how you can get a list of installed Windows fonts using Python:
Python
This code will first import the
winreg
module, which is used to access the Windows registry. Then, it will define a function calledget_installed_fonts()
. This function will get the registry key for the installed fonts and enumerate the values in the key. For each value, it will get the font path and add it to a list. Finally, the function will return the list of fonts.The
get_installed_fonts()
function can be called from the main body of the program. This will print a list of all the installed Windows fonts to the console.